package com.yanxi.service.impl;

import com.yanxi.mapper.EmpMapper;
import com.yanxi.mapper.StudentMapper;
import com.yanxi.pojo.JobOption;
import com.yanxi.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private StudentMapper  studentMapper;
    @Override
    public JobOption getEmpJobData() {
        //调用mapper接口
        List<Map<String, Object>> List = empMapper.CountEmpJobData();
        //封装数据
        List<Object> jobList = List.stream().map(data -> data.get("pos")).toList();
        List<Object> dataList = List.stream().map(data -> data.get("num")).toList();
        return new JobOption(jobList,dataList);
    }

    @Override
    public List<Map<String, Object>> getEmpGenderData() {
        //调用mapper接口
        List<Map<String, Object>> list = empMapper.CountEmpGenderData();
        return list;
    }

    //班级人数统计
    @Override
    public JobOption getStudentCountData() {
        //调用mapper接口
        List<Map<String, Object>> List = studentMapper.CountStudentCountData();
        //封装数据
        List<Object> jobList = List.stream().map(data -> data.get("clazzName")).toList();
        List<Object> dataList = List.stream().map(data -> data.get("num")).toList();
        return  new JobOption(jobList,dataList);
    }


    //学生性别统计
    @Override
    public List<Map<String, Object>> getStudentDegreeData() {

        return studentMapper.CountStudentDegreeData();
    }
}
